﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Pap.Web.Utils;
using Pap.Data;
using System.Data.Linq.SqlClient;

namespace Pap.Web.Modules.Administration.ViewModel
{
    public class ImagesSearchViewModel : IViewModel
    {
        IImageRepository _imageRepository;
        
        public ImagesSearchViewModel(IImageRepository imageRepossitory)
        {
            _imageRepository = imageRepossitory;
        }

        public IEnumerable<IImage> FindImages(string key, Nullable<Guid> type)
        {
            return _imageRepository.FindImage(image => SqlMethods.Like(image.Label, "%" + key + "%") && (type == null || image.ImageTypeID == type));
        }

        internal  IEnumerable<ILookUpEntity> GetImageTypes()
        {
            return _imageRepository.GetImageTypes();
        }

        
    }
}